package com.soup.lab.repository;

import com.soup.lab.repository.dao.FruitMapper;
import com.soup.lab.repository.model.Fruit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.concurrent.TimeUnit;

@Service
@Transactional
public class OtherServiceImpl implements OtherService {

    private static final Logger logger = LoggerFactory.getLogger(OtherServiceImpl.class);

    @Autowired
    private FruitMapper fruitMapper;

    @Override
    public void doSync(Integer id) {
        Fruit fruit = fruitMapper.selectByPrimaryKey(id);
        logger.info("fruit: "+ fruit);
        try {
            TimeUnit.SECONDS.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Fruit fruit1 = fruitMapper.selectByPrimaryKey(id);
        logger.info("fruit1: "+ fruit1);
    }

}
